<!DOCTYPE html>
<html>
<head>
	<title>餐饮营销支持系统</title>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link href="../../css/bootstrap.min.css" rel="stylesheet">
	<!-- <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"> -->
	<link rel="stylesheet" type="text/css" href="../../css/waiter.css">
	<link rel="stylesheet" type="text/css" href="../../css/boss.css">
</head>
<body>
	<div id="head">
		<div class="navbar navbar-default  navbar-inverse" role="navigation">
			<div class="navbar-header">
				<a href="##" class="navbar-brand">餐饮营销支持系统</a>
			</div>
			<!-- 	<a href="javascript:if(confirm('确定要推出登录吗?'))location='sign.html'"> -->
				<button type="submit" class="btn btn-danger">
					<span style="margin-right: 5px" class="glyphicon glyphicon-off"></span>注销
				</button>
				<!-- </a> -->
			</div>

		</div>

		<div id="left">

			<p class="left-head">
			boss登录</p>

			<div class="container">
				<div class="row" style="margin-top: 0px">
					<a href="./boss.html">
						<div class="col-md-12">
							<span class="glyphicon glyphicon-user"></span>
							<p>个人信息</p>
						</div>
					</a>
				</div>
				<div class="row">
					<a href="./boss-two.html">
						<div class="col-md-12">
							<span class="glyphicon glyphicon-home"></span>
							<p>店铺管理</p>
						</div>
					</a>
				</div>
				<div class="row">
					<a href="./boss-three.html">
						<div class="col-md-12">
							<span class="glyphicon glyphicon-plus-sign"></span>
							<p>店铺人员</p>
						</div>
					</a>
				</div>
				<div class="row act">

					<div class="col-md-12">
						<span class="glyphicon glyphicon-list"></span>
						<p>菜单管理</p>
					</div>
					
				</div>
				<div class="row">
					<a href="./boss-five.html">
						<div class="col-md-12">
							<span class="glyphicon glyphicon-retweet"></span>
							<p>收益比例</p>
						</div>
					</a>
				</div>

				<div class="row">
					<a href="./boss-six.html">
						<div class="col-md-12">
							<span class="glyphicon glyphicon-th"></span>
							<p>收入查询</p>
						</div>
					</a>
				</div>
				
			</div>
		</div>

		<div id="right">
			<div class="right-head">
				<ol class="breadcrumb">
					<li><a href="#">首页</a></li>
					<li class="active">菜单管理</li>
				</ol> 
			</div>
			<div class="con">
				<div class="container">
					<div class="row">
						<div class="col-md-12">
							<div class="panel panel-default">
								<div class="panel-body">
									<div class="row pan-head" style="margin-bottom: 10px">
										<p>
											菜单管理
										</p>
										<div class="pan-headB">
											<button type="submit" class="btn btn-primary" id="btn-add">
												<span style="margin-right: 5px" class="glyphicon glyphicon-plus"></span>添加
											</button>
										</div>
									</div>
									<div class="row">
									<label class="col-lg-2 control-label">
										地区：
									</label>
									<div class="col-lg-2">
										<select name="省" class="form-control" id = "provinces"> 
										</select>
									</div>
									<div class="col-lg-2">
										<select name="市" class="form-control" id = "citys"> 
										</select>
									</div>
									<div class="col-lg-2">
										<select name="县" class="form-control" id = "adress"> 
										</select>
									</div>
									<label class="col-lg-1 control-label">
										类别：
									</label>
									<div class="col-lg-2">
										<select name="分类" class="form-control" id="foodtype"> 
											<option value="1">炒菜</option>
											<option value="2">炖菜</option>
											<option value="3">涮菜</option>
											<option value="4">凉菜</option>
											<option value="5">主食</option>
											<option value="6">酒水</option>
											<option value="7">其他</option>
										</select>
									</div>
								</div>
									<!-- <div class="col-xs-12 col-md-3">
										<a href="#" class="thumbnail">
											<img src="../../images/menu.jpg">
										</a>
										<div class="caption">
											<h3>小炒肉</h3>
											<p>
												<span>（</span>
												<span class="la">辣</span>
												<span>/</span>
												<span class="fen">3人份</span>
												<span>）</span>
											</p>
											<p>小炒肉是湖南省一道常见的特色传统名菜，属于湘菜系。class="la"麻辣鲜香，口味滑嫩。制作原料主要是五花肉和青椒、红椒等...</p>
											<p class="money"><span>￥</span>44<span>.00</span>
												<button class="twoAlter btn btn-primary btn-sm" type="button" name="alter-1">修 改</button> 
											</p>
											
										</div>  
									</div> -->
									<div class="row">
										<div class="col-lg-10 col-lg-offset-1">
											<div class="table-responsive">
												<table class="table table-striped table-bordered table-hover">
													<thead>
														<tr>
															<th>菜名</th>
															<th>口味</th>
															<th>分量</th>
															<th>价格</th>
															<th>修改</th>
														</tr>
													</thead>
													<tbody id="foods">
													</tbody>
												</table>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<script src="../../js/Jquary/jquery-3.2.1.min.js"></script>
		<script src="../../js/Jquary/jquery.easyui.min.js"></script>
		<script src="../../js/bootstrap.min.js"></script>
		<script type="text/javascript" src="../../js/logout.js"></script>
		<script type="text/javascript" src="../../js/adress.js"></script>
		<script type="text/javascript">
			$(document).ready(function(){
				$("#foods").on('click', '.remove',function(){
					var r=confirm("你确定删除！");
					if (r==true){	
						var menuid = $(this).attr("name");
						deleteMenu(menuid);
					}
				});
				
				$("#btn-add").click(function(){
					window.location.href="./add-menu.html";
				});
				
				$("#foodtype").change(function(){
					getFoodsByAdress();
				})
				
				getAdress();
				getFoodsByAdress();
				
			})
		</script>
		<script type="text/javascript">
			function deleteMenu(menuid){
				$.ajax({
					type:"get",
					url:"/ldss/menus/remove",
					async:false,
					data:{
							menuid:menuid
						},
					dataType:"json",
					success: function (data) {
						if(data.success){
							var data = data;
							alert(data.message);
							 getFoodsByAdress();
						}else{
							alert(data.message);
						}
					}
				});
			}
			
			function getFoodsByAdress(){
				var foodtype = $("#foodtype").val();
				var adressid = $("#adress").val();
				if(adressid==-1||adressid==null){
					return;
				};
				$.ajax({
					type:"get",
					url:"/ldss/menus/seeAdressmenu",
					async:false,
					data:{
							adressid:adressid,
							foodtype:foodtype
						},
					dataType:"json",
					success: function (data) {
						if(data.success){
							var data = data.data;
							$("#foods").empty();
							for(var i = 0; i < data.length; i++){
								$("#foods").append(
									"<tr>"+
										"<td>"+data[i].foodName+"</td>"+
										"<td>"+data[i].foodFlavor+"</td>"+
										"<td>"+data[i].foodWeight+"</td>"+
										"<td>"+data[i].foodPrice+"</td>"+
										"<td>"+ 
											"<button type='button' class='btn btn-primary remove' name='"+data[i].id+"'>删除</button>"+
										"</td>"+
									"</tr>"
								);
							}
						}else{
							alert(data.message);
						}
					}
				});
			}
		</script>
	</body>
	</html>